'''
Created on Apr 1, 2012

@author: lyle
'''
import json
import validictory

class Package(object):
    '''
    classdocs
    '''


    def __init__(self, jsonf):
        '''
        Constructor
        '''
        if isinstance(jsonf, str): #file path
#            self.manifest = json.load(open(jsonf, 'r'), encoding="UTF-8")
            
#            try:
#                validictory.validate("simplejson", str)
#            except ValueError, error:
#                print error
            self.manifest = json.loads(jsonf)
            
        elif isinstance(jsonf, file): #file pointer
            self.manifest = json.load(jsonf, encoding="UTF-8")
        else:
            self.manifest = None
    
        self.dot = None
        
    def dependency2dot(self):
        dep = self.manifest['dependencies']
        for d in dep:
            print d['name']
        